<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:rich="http://richfaces.org/rich"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:s="http://jboss.org/seam/faces"
      xmlns:fn="http://java.sun.com/jsp/jstl/functions"
      xml:lang="en" lang="en">

<ui:composition template="/resources/layout.xhtml">
    <ui:define name="title" >Филиалы системы</ui:define>
    <ui:define name="content">
        <h:form id="filialListForm">
            <rich:dataTable value="#{filialAction.filialList}" var="filial" id="filialList">
                <rich:column>
                    <f:facet name="header">
                        <h:outputText value="Аббревиатура"/>
                    </f:facet>
                    <div>
                        <rich:inplaceInput defaultLabel="аббревиатура..."
                                           value="#{filial.abbreviation}"
                                           rendered="#{filial.abbreviation != 'multiFilial'}" >
                            <a4j:ajax event="change" />
                        </rich:inplaceInput>
                        <h:outputText value="#{filial.abbreviation}" rendered="#{filial.abbreviation == 'multiFilial'}"/>
                    </div>
                </rich:column>

                <rich:column styleClass="number-column">
                    <f:facet name="header">
                        <h:outputText value="Капитал"/>
                    </f:facet>
                    <div>
                        <rich:inplaceInput defaultLabel="капитал..."
                                           rendered="#{filial.abbreviation != 'multiFilial'}"
                                           value="#{filial.capital}">
                            <f:convertNumber pattern="###,##0.0" />
                            <a4j:ajax event="change"  oncomplete="rerenderFilialList()" listener="#{filialAction.recalculateMultiFilialAmount()}" />
                        </rich:inplaceInput>
                        <h:outputText value="#{filial.capital}" rendered="#{filial.abbreviation == 'multiFilial'}">
                            <f:convertNumber pattern="###,##0.0" />
                        </h:outputText>
                    </div>
                </rich:column>

                <rich:column>
                    <f:facet name="header">
                        <h:outputText value="Наименование"/>
                    </f:facet>
                    <div>
                        <rich:inplaceInput defaultLabel="наименование..." value="#{filial.name}" >
                            <a4j:ajax event="change" />
                        </rich:inplaceInput>
                    </div>
                </rich:column>
            </rich:dataTable>
            <a4j:jsFunction name="rerenderFilialList" render="filialList"/>
        </h:form>
    </ui:define>
</ui:composition>

</html>
